package date

import "time"

type Date struct {}

const TIMELAYOUT = "2006-01-02 15:04:05"

// GetTimestamp 获取当前时间时间戳
func (d *Date) GetTimestamp() int64 {
	return time.Now().Unix()
}

// GetDateTime 获取当前时间
func  (d *Date) GetDateTime() string {
	return time.Now().Format(TIMELAYOUT)
}

// TimeToUnix 时间格式转换为时间戳
func  (d *Date) TimeToUnix(dateStr string) int64 {
	loc := time.Local
	t,_ := time.ParseInLocation(TIMELAYOUT, dateStr, loc)
	return t.Unix()
}

// UnixToTime 时间戳转换为时间
func  (d *Date) UnixToTime(data int64) string {
	return time.Unix(data, 0).Format(TIMELAYOUT)
}

// RfcToTimeString RFC时间转化为标准时间格式的字符串
func  (d *Date) RfcToTimeString(rfcTime string) string {
	t1, _ := time.Parse(time.RFC3339, rfcTime)
	return t1.Format(TIMELAYOUT)
}

